﻿using System;
using System.IO;

namespace Union_Find
{
    class UFData
    {
        internal UFData(string fileName)
        {
            var content = File.ReadAllText(fileName);
            var strarray = content.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            Length = Convert.ToInt32(strarray[0]);
            Connections = new int[strarray.Length - 1][];
            for (var i = 1; i < strarray.Length; i++)
            {
                var connections = strarray[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                Connections[i - 1] = new int[2] { Convert.ToInt32(connections[0]), Convert.ToInt32(connections[1]) };
            }
        }
        public int Length { get; set; }

        public int[][] Connections { get; set; }
    }
}
